unit office;

{$mode objfpc}{$H+}

interface

uses
  Classes,
  SysUtils,
  hadeobject;

type

  { TOffice }

  TOffice = class(THadeObject)
  private
    fEmail: string;
    fOfficeAddress: string;
    fOfficeName: string;
    fPhone: string;
    fWeb: string;
  published
    property OfficeName: string read fOfficeName write fOfficeName;
    property OfficeAddress: string read fOfficeAddress write fOfficeAddress;
    property Phone: string read fPhone write fPhone;
    property Web: string read fWeb write fWeb;
    property Email: string read fEmail write fEmail;
  end;

  { TOfficeList }

  TOfficeList = class(THadeObjectList)
  private
  protected
    function getItem(index: integer): TOffice;Reintroduce;
  public
    property Items[index:integer] :TOffice read getItem;

    //procedure getAll();
    //procedure getFirst();
  end;

  procedure RegisterMapping;

//var
//  lsession: THadeSession;

implementation

uses
  hademapping;

Procedure RegisterMapping;
begin
  GHadeMappingManager.RegisterMapping('test',TOffice, 'office', 'OID', 'oid',
    ftInteger, 0, [ptkPK, ptkReadOnly]);

  GHadeMappingManager.RegisterMapping('test',TOffice, 'Office', 'OfficeName',
    'office_name', ftVarchar, 50);

  GHadeMappingManager.RegisterMapping('test',TOffice, 'office',
    'OfficeAddress',
    'office_address', ftString);

  GHadeMappingManager.RegisterMapping('test',TOffice, 'office', 'Phone',
    'phone', ftVarchar, 16);

  GHadeMappingManager.RegisterMapping('test',TOffice, 'office', 'Web',
    'web', ftVarchar, 50);

  GHadeMappingManager.RegisterMapping('test',TOffice, 'office', 'Email',
    'email', ftVarchar, 50);

  GHadeMappingManager.RegisterObjectList('test',TOfficeList,TOffice);

  //lsession := GHadeSessionFactory.CreateSession('test');
end;

{ TOfficeList }

function TOfficeList.getItem(index: integer): TOffice;
begin
  Result:=TOffice(inherited getItem(index));
end;

//procedure TOfficeList.getAll;
//begin
//  lsession.Read(self);
//end;
//
//procedure TOfficeList.getFirst;
//begin
//  lsession.Read(self,0,1);
//end;

end.

